import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 客户类
 */
public class Customer {
    private String name;                // 姓名
    private String contact;             // 联系电话
    private String deliveryAddress;     // 邮寄地址
    private boolean active;             // 是否激活
    private List<Order> orders = new ArrayList<>(); // 客户的订单（0到多）

    // 创建订单
    public Order createOrder() {
        Order order = new Order(this);
        orders.add(order);
        return order;
    }
}

/**
 * 订单类
 */
public class Order {
    private Date createDate;            // 创建日期
    private String status;              // 状态（CREATE/PAID等）
    private Customer customer;          // 所属客户
    private List<OrderDetail> details = new ArrayList<>(); // 订单详情（1到多）
    private Payment payment;            // 支付方式（1个）

    public Order(Customer customer) {
        this.customer = customer;
        this.createDate = new Date();   // 默认为当前时间
        this.status = "CREATE";         // 初始状态
    }

    // 添加订单详情（组合关系）
    public void addOrderDetail(Product product, int quantity) {
        OrderDetail detail = new OrderDetail(product, quantity);
        details.add(detail);
    }

    // 设置支付方式
    public void setPayment(Payment payment) {
        this.payment = payment;
        this.status = "PAID"; // 支付后状态更新
    }
}

/**
 * 订单详情类
 */
public class OrderDetail {
    private int quantity;       // 数量
    private Product product;    // 关联商品

    public OrderDetail(Product product, int quantity) {
        this.product = product;
        this.quantity = quantity;
    }

    // 计算小计（数量×单价）
    public double calculateSubTotal() {
        return product.getPriceForQuantity(quantity);
    }

    // 计算重量（数量×商品重量）
    public double calculateWeight() {
        return product.getWeight() * quantity;
    }
}

/**
 * 商品项类
 */
public class Product {
    private String title;       // 名称
    private double weight;      // 重量
    private String description; // 描述
    private double unitPrice;   // 单价（补充属性，用于计算）

    // 按数量获取价格
    public double getPriceForQuantity(int quantity) {
        return unitPrice * quantity;
    }

    // 获取重量
    public double getWeight() {
        return weight;
    }
}

/**
 * 支付方式父类
 */
public abstract class Payment {
    protected double amount;    // 金额

    public Payment(double amount) {
        this.amount = amount;
    }
}

/**
 * 信用卡支付
 */
public class Credit extends Payment {
    private String number;      // 卡号
    private String type;        // 类型
    private Date expireDate;    // 过期日期

    public Credit(double amount, String number, String type, Date expireDate) {
        super(amount);
        this.number = number;
        this.type = type;
        this.expireDate = expireDate;
    }
}

/**
 * 现金支付
 */
public class Cash extends Payment {
    private double cashTendered; // 支付金额

    public Cash(double amount, double cashTendered) {
        super(amount);
        this.cashTendered = cashTendered;
    }
}

/**
 * 在线转账
 */
public class WireTransfer extends Payment {
    private String bankID;      // 银行ID
    private String bankName;    // 银行名称

    public WireTransfer(double amount, String bankID, String bankName) {
        super(amount);
        this.bankID = bankID;
        this.bankName = bankName;
    }
}

/**
 * 支付宝支付
 */
public class AliPay extends Payment {
    private String number;      // 卡号

    public AliPay(double amount, String number) {
        super(amount);
        this.number = number;
    }
}

/**
 * 微信支付
 */
public class WeixinPay extends Payment {
    private String number;      // 卡号

    public WeixinPay(double amount, String number) {
        super(amount);
        this.number = number;
    }
}